package thinking

object 模式匹配 {
  def main(args: Array[String]): Unit = {

    val operator = '+'
    val n1 = 20
    val n2 = 10
    var res: Int = 0

    operator match {
      case '+' => res = n1 + n2
      case '-' => res = n1 - n2
      case '*' => res = n1 * n2
      case '/' => res = n1 / n2
      case _ => println("输入正确运算符！")
    }
    println("res=" + res)
  }

}
